﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using CSP.Model.CSP;

namespace CSP.DataAccess.Mapping
{
    public class ServiceInfoAddressRelMap : EntityTypeConfiguration<ServiceInfoAddressRel>
    {
        public ServiceInfoAddressRelMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("ServiceInfoAddressRel");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.AddressId).HasColumnName("AddressId");
            this.Property(t => t.ServiceInfoId).HasColumnName("ServiceInfoId");

            // Relationships
            this.HasRequired(t => t.Address)
                .WithMany(t => t.ServiceInfoAddressRels)
                .HasForeignKey(d => d.AddressId);
            this.HasRequired(t => t.ServiceInfo)
                .WithMany(t => t.ServiceInfoAddressRels)
                .HasForeignKey(d => d.ServiceInfoId);

        }
    }
}
